#include "stimpack_exercise_JNIfunctionActivity.h"

JNIEXPORT jobject JNICALL Java_stimpack_exercise_JNIfunctionActivity_createJniObject
	(JNIEnv *env, jclass clazz){

		jclass targetClass;
		jmethodID mid;
		jobject newObject;
		jstring helloStr;
		jfieldID fid;
		jint staticIntField;
		jint result;

		fid = env-> GetStaticFieldID(clazz, "staticIntField", "I");
		staticIntField = env->GetStaticIntField(clazz, fid);

		targetClass = env-> FindClass("stimpack/exercise/JniTest");

		mid = env-> GetMethodID(targetClass, "<init>", "(I)V");

		newObject = env->NewObject(targetClass, mid, 100);

		mid = env->GetMethodID(targetClass, "callByNative", "(I)I");
		result = env-> CallIntMethod(newObject, mid, 200);

		fid = env-> GetFieldID(targetClass, "intField", "I");
		env-> SetIntField(newObject, fid, result);
		return newObject;

	}